package com.briup.web;

import com.briup.bean.CallLog;
import com.briup.bean.CallPer;
import com.briup.bean.Consume;
import com.briup.bean.Plan;
import com.briup.service.ICalllogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author adam
 * @date 2023/2/26
 */
@Controller
public class CallController {
    @Autowired
    ICalllogService calllogService;


    @GetMapping("callLog")
        public String callLog(String tel,String callTime,HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

            List<CallLog> logs = calllogService.queryMonthDatas(tel, callTime);
            Plan plan = calllogService.queryCurrRemainder(tel, callTime);
            CallPer callPer = calllogService.queryPerRemainder(tel, callTime);
            List<Consume> list = calllogService.queryMonthConsume(tel, callTime);
            Consume consume = calllogService.queryYearConsume(tel, callTime);
            req.setAttribute("callLogs",logs);
            req.setAttribute("plan",plan);
            req.setAttribute("callPer",callPer);
            req.setAttribute("list",list);
            req.setAttribute("consume",consume);
            req.setAttribute("rand1",java.lang.Math.round(java.lang.Math.random() * 100) );
            req.setAttribute("rand2",java.lang.Math.round(java.lang.Math.random() * 1000) );
            return "index";
        }



}
